package cz.semjob.learning.learner;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import weka.classifiers.Classifier;
import weka.classifiers.functions.SMO;
import weka.core.Instances;
import cz.semjob.learning.classifier.LearningException;

@Component
public class SVMDataSetLearner implements IDataSetLearner {

	private static Logger logger = Logger.getLogger(SVMDataSetLearner.class);

	public String getInfo() {
		return "SVM";
	}

	public Classifier buildClassifier(Instances instances)
			throws LearningException {
		// RandomForest classifier = new RandomForest();

		SMO classifier = new SMO();
		// classifier.setUnpruned(true);
		// classifier.setConfidenceFactor(0.1f);
		// classifier.setBinarySplits(true);
		// classifier.setNumFolds(3);

		try {
			classifier.buildClassifier(instances);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e);
			throw new LearningException(e);
		}
		return classifier;
	}
}
